﻿<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0, user-scalable=no">
    <title>重置密码</title>
    <link rel="stylesheet"
          href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <!--<link rel="stylesheet"
          href="dist/css/bootstrap.min.css">
    <script src="dist/js/jquery-2.1.4.min.js"></script>
    <script src="dist/js/bootstrap.min.js"></script>-->
    
    <script type="text/javascript">
    var xmlhttp;
	var result;
	function createXMLHttpRequext() {
		if (window.ActiveXObject) {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} else if (window.XMLHttpRequest) {
			xmlhttp = new XMLHttpRequest();
		}
	}
	function repassword() {
		var userNumber = document.getElementById("firstname").value;
		var password = document.getElementById("inputPassword").value;
		var againPassword = document.getElementById("rePassword").value;
		var choice = document.getElementById("choice").value;
		var safecode = document.getElementById("answer").value;
		createXMLHttpRequext();
		xmlhttp.open("POST","RePassword",true);
		xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		//xmlhttp.setRequestHeader("Content-Type", "text/html;charset=UTF-8");
		xmlhttp.onreadystatechange = resultCallback;
		xmlhttp.send("userNumber=" + userNumber + "&password=" + password + "&againPassword=" + againPassword + "&choice=" + choice + "&safecode=" + safecode);
	}
	function resultCallback() {
		if (xmlhttp.readyState == 4) {
			result = xmlhttp.responseText;
			if(result == "0"){//返回0表示修改成功
				if (confirm("修改成功，跳转到登录")){
					window.location.href="login.jsp";
				} 
			}else{
				alert(result);
			}
		}
	}
    
    </script>
    
</head>
<body style="background-image: url(images/login_bg_0.jpg);background-size:cover">
<div class="container">
    <div class="row clearfix ">
        <div class="col-md-4 column">
        </div>
        <div class="col-md-4 column">
        <div class="panel panel-info"style="margin-right: auto;margin-left: auto;margin-top: 50px;box-shadow: #666 0px 0px 10px">
            <div class="panel-heading">
                <p class="text-center h4"><img alt="140x140" src="images/favicon.ico"
                                               class="img-circle" width=25px/>重置密码</p>
            </div>
            <div  class="panel-body">
                <div class="form-horizontal">
                    <div class="form-group">
                        <div class="col-sm-10" style="margin-left:8%">
                            <span class="glyphicon glyphicon-user"
                                  style="position: absolute;top: 10px;left: 25px"></span>
                            <input type="text" class="form-control" id="firstname" name="userNumber"
                                   placeholder="请输入学号" style="padding-left: 30px">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-10" style="margin-left:8%">
                                <select class="form-control" name="choice" id="choice">
                                    <option value="1">我的生日是？</option>
                                    <option value="2">我母亲的名字是？</option>
                                    <option value="3">我出生的地点是？</option>
                                    <option value="4">我最喜欢的运动是？</option>
                                    <option value="5">我最喜欢的一首歌是？</option>
                                </select>
                                <input type="text" class="form-control" id="answer" name="safecode"
                                       placeholder="请输入密保答案" style="margin-top: 15px">
                         </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-10" style="margin-left:8%">
                            <span class="glyphicon glyphicon-eye-close"
                                  style="position: absolute;top: 10px;left: 25px"></span>
                            <input type="password" class="form-control" id="inputPassword" name="password"
                                   placeholder="请输入新的密码" style="padding-left: 30px">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-10" style="margin-left:8%">
                            <span class="glyphicon glyphicon-eye-close"
                                  style="position: absolute;top: 10px;left: 25px"></span>
                            <input type="password" class="form-control" id="rePassword" name="againPassword"
                                   placeholder="请再次输入新的密码" style="padding-left: 30px">
                        </div>
                    </div>
                    
                    <hr style="margin-top: 30px">
                    <button class="btn btn-primary btn-sm" type="submit" style="float: left;margin-left: 100px" onclick="repassword()">确定</button>
                    <a class="btn btn-primary btn-sm" style="float: left;margin-left: 10px" href="login.jsp" role="button">返回</a>
                </div>
            </div>
        </div>
        </div>
        <div class="col-md-4 column">
        </div>
    </div>
</div>
</body>
</html>
